package com.ryskoo.catering.dinnertabletype.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.dinnertabletype.domain.DinnerTableTypePO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

@Repository
@Primary
public class DinnerTableTypeRedisImpl extends BasicRedisImpl<DinnerTableTypePO> implements IDinnerTableTypeRepository {

    @Autowired
    private RedisUtil redisClient;

    @Autowired
    private IDinnerTableTypeRepository dinnerTableTypeRepository;

    @PostConstruct
    public void init() {
        this.setRedisClient(redisClient);
        this.setDao(dinnerTableTypeRepository);
    }

    public DinnerTableTypeRedisImpl(){super(HCLCacheConstant.HCL_DINNERTABLECATEGORY_KEY);}

    @Override
    public List<DinnerTableTypePO> getListByVendorId(String vendorId) {
        return dinnerTableTypeRepository.getListByVendorId(vendorId);
    }

    @Override
    public List<String> getUuidByNameAndVendorId(String name, String vendorId) {
        return dinnerTableTypeRepository.getUuidByNameAndVendorId(name,vendorId);
    }

    @Override
    public List<String> getUuidByNameAndVendorIdForUpdate(String name, String vendorId, String uuid) {
        return dinnerTableTypeRepository.getUuidByNameAndVendorIdForUpdate(name,vendorId,uuid);
    }
}
